<?php

namespace App\Http\Requests;

/**
 * 微信自定义菜单验证器
 * @package App\Http\Requests
 */
class AdminWxMenuPost extends AdminBaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required',
            'type' => 'required',
            'key' => 'required_if:type,click,scancode_waitmsg,scancode_push,pic_sysphoto,pic_photo_or_album,pic_weixin,location_select',
            'url' => 'required_if:type,view,miniprogram',
            'appid' => 'required_if:type,miniprogram',
            'pagepath' => 'required_if:type,miniprogram',
            'media_id' => 'required_if:type,media_id,view_limited',
            'order_num' => 'integer|min:0',
        ];
    }

    /**
     * 定义错误信息
     * @return array
     */
    public function messages()
    {
        return [
            'name.required' => '菜单名称不能为空',
            'type.required' => '请选择菜单类型',
            'key.required_if' => '菜单KEY值不能为空',
            'url.required_if' => '网页链接不能为空',
            'appid.required_if' => '小程序appid不能为空',
            'pagepath.required_if' => '小程序页面路径不能为空',
            'media_id.required_if' => '永久素材mediaId不能为空',
            'order_num.min' => '排序数值必须大于或等于0',
        ];
    }
}
